﻿-- Define the relationship between CategoryRoleAccess and SecurityRole
ALTER TABLE [dbo].[CategoryRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_CategoryRoleAccess_SecurityRole] FOREIGN KEY([SecurityRole])
REFERENCES [dbo].[SecurityRole] ([RoleId])
ON DELETE NO ACTION
GO
-- Define the relationship between CategoryRoleAccess and Category
ALTER TABLE [dbo].[CategoryRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_CategoryRoleAccess_Category] FOREIGN KEY([Category])
REFERENCES [dbo].[Category] ([CategoryId])
ON DELETE NO ACTION
GO
-- Define the relationship between CategoryRoleAccess and Person
ALTER TABLE [dbo].[CategoryRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_CategoryRoleAccess_CreatedByPerson] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between CategoryRoleAccess and Person
ALTER TABLE [dbo].[CategoryRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_CategoryRoleAccess_LastChangedBy] FOREIGN KEY([LastChangedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between CategoryRoleAccess and Person
ALTER TABLE [dbo].[CategoryRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_CategoryRoleAccess_Person] FOREIGN KEY([Person])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO